
cmake_minimum_required (VERSION 3.1)

# cmake -DCMAKE_TOOLCHAIN_FILE=../fuxi_setup.cmake -DDEBUG=ON ..

project(devinfo_test C)


# 设置 C 标准为 C99
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED True)

# debug message
option(DEBUG "debug flag..." OFF)
if(DEBUG)
add_definitions(-DDEBUG -DDEBUG_TIME)
endif(DEBUG)

add_definitions(-DTESTING)

# ---  CUnit 配置 ---
# 设置 CMake 模块路径
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}" ${CMAKE_SOURCE_DIR})

message("Compiler name:  ${CMAKE_C_COMPILER}") 


# 查找 CUnit 包
find_package(CUnit REQUIRED )

# 包含 CUnit 头文件路径
include_directories(${CUNIT_INCLUDE_DIR})

# --- 源文件列表 ---
file(GLOB SOURCES
    "${PROJECT_SOURCE_DIR}/*.c"
    "${PROJECT_SOURCE_DIR}/../src/*.c"
)

# 从列表中移除 测试用程序 文件
set(EXCLUDE_FILE "${PROJECT_SOURCE_DIR}/../src/dtree.c")
list(REMOVE_ITEM SOURCES ${EXCLUDE_FILE})

# --- 包含目录 ---
include_directories(
    "${PROJECT_SOURCE_DIR}/"
    "${PROJECT_SOURCE_DIR}/../include"
)
message("PROJECT_SOURCE_DIR:  ${PROJECT_SOURCE_DIR}") 


# 添加测试可执行文件
add_executable(${PROJECT_NAME}  ${SOURCES})

# 链接 CUnit 和你的库
target_link_libraries(${PROJECT_NAME} libcunit.so)